package view 
{
	import controller.GameController;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	/**
	 * ...
	 * @author bimkute
	 */
	public class Base extends MovieClip 
	{
		protected var content:MovieClip;
		private static var instance:Base;
		public function Base() 
		{
			
		}
		
		public static function getInstance():Base 
		{
			if (!instance) 
			{
				instance = new Base();
			}
			return instance;
		}
		
		protected function addContent(str:String, nameSwf:String):void 
		{
			content = getImage(str, nameSwf);
			trace("dc add ra roi: ", content)
			addChild(content);
		}
		
		public function getImageMC(str1:String, nameSwf1:String):MovieClip 
		{
			var mc1:MovieClip = GameController.getInstance().getClass(str1, nameSwf1);
			return mc1;
		}
		
		protected function getImage(str:String, nameSwf:String):MovieClip 
		{
			var mc:MovieClip = GameController.getInstance().getClass(str, nameSwf);
			return mc;
		}
		
		protected function removeContent():void 
		{
			removeChild(content);
			content = null;
		}
		
		protected var _shadow:Sprite;
		protected function createShadow():void 
		{
			if (!_shadow) 
			{
				_shadow = new Sprite();
				_shadow.graphics.beginFill(0x000000, .4);
				_shadow.graphics.drawRect(0, 0, 1400, 900);
				_shadow.graphics.endFill();
				addChild(_shadow);
			}
			
			//_shadow.visible = false;
		}
		protected function clearShadow():void 
		{
			if (_shadow) 
			{
				removeChild(_shadow);
				_shadow = null;
			}
			/**/
		}
		
		protected function format(number:int):String 
		{
			var numString:String = number.toString()
			var result:String = '';

			while (numString.length > 3)
			{
					var chunk:String = numString.substr(-3)
					numString = numString.substr(0, numString.length - 3)
					result = ',' + chunk + result
			}

			if (numString.length > 0)
			{
					result = numString + result
			}

			return result
		}
	}

}